// Wait until the DOM has loaded before querying the document
$(document).ready(function() {
    /*$('.close').click(function() {
     $('#right-menu').removeClass('hide');
     });*/
    //var url = 'http://www.webdesignius.com/portfolio/newidu/';
    //var url = 'http://newidu.local/';
    //var url = window.location.protocol + "//" + window.location.host + '/portfolio/newidu/';
    var url = window.location.protocol + "//" + window.location.host + '/';
    $('#marca').change(function() {
        var dataString = $('#search').serialize();
        $.ajax({
            url: url + 'site/ajax_call',
            type: 'POST',
            dataType: 'json',
            data: dataString,
            cache: false,
            beforeSend: function() {
                $('#loader').show();
                $('#results').html('').show();
            },
            success: function(output_string) {
                $('#loader').hide();
                $('#search-results').show();
                $('#results').append(output_string);
                $(".anyClass").jCarouselLite({
                    btnNext: ".next",
                    btnPrev: ".prev"
                });
            }
        }, 10000);
        return false;
    });

    $('#categoria').change(function() {
        $('#results').html('');
        var dataString = $('#search').serialize();
        $.ajax({
            url: url + 'site/ajax_call',
            type: 'POST',
            dataType: 'json',
            data: dataString,
            cache: false,
            beforeSend: function() {
                $('#loader').show();
                $('#results').html('').show();
            },
            success: function(output_string) {
                $('#loader').hide();
                $('#search-results').show();
                $('#results').append(output_string);
                $(".anyClass").jCarouselLite({
                    btnNext: ".next",
                    btnPrev: ".prev"
                });
            }
        });
        return false;
    });

    $('#combustible').change(function() {
        $('#results').html('');
        var dataString = $('#search').serialize();
        $.ajax({
            url: url + 'site/ajax_call',
            type: 'POST',
            dataType: 'json',
            data: dataString,
            cache: false,
            beforeSend: function() {
                $('#loader').show();
                $('#results').html('').show();
            },
            success: function(output_string) {
                $('#loader').hide();
                $('#search-results').show();
                $('#results').append(output_string);
                $(".anyClass").jCarouselLite({
                    btnNext: ".next",
                    btnPrev: ".prev"
                });
            }
        });
        return false;
    });

    $('#cita').submit(function() {
        $('#citas-results').html('');
        var dataString = $(this).serialize();
        $.ajax({
            url: url + 'site/ajax_citas_call',
            type: 'POST',
            dataType: 'json',
            data: dataString,
            cache: false,
            beforeSend: function() {
                //$('#loader').show();
                //$('#results').html('');
            },
            success: function(output_string) {
                //$('#loader').hide();
                $('#citas-results').html(output_string);
            }
        });
        return false;
    });
    $('#consulta').submit(function() {
        $('#consultas-results').html('');
        var dataString = $(this).serialize();
        $.ajax({
            url: url + 'site/ajax_consultas_call',
            type: 'POST',
            dataType: 'json',
            data: dataString,
            cache: false,
            beforeSend: function() {
                //$('#loader').show();
                //$('#results').html('');
            },
            success: function(output_string) {
                //$('#loader').hide();
                $('#consultas-results').html(output_string);
            }
        });
        return false;
    });
});
$(function() {
    window.prettyPrint && prettyPrint();
    /*$('#dp1').fdatepicker({
     format: 'mm-dd-yyyy'
     });
     $('#dp2').fdatepicker({
     closeButton: true
     });*/
    //$('#dp3').fdatepicker();
    //$('#dp3').fdatepicker();
    //$('#dp-margin').fdatepicker();
    //$('#dpYears').fdatepicker();
    //$('#dpMonths').fdatepicker();
    //var startDate = new Date(2013, 1, 3);
    //var endDate = new Date(2013, 12, 31);


    // implementation of disabled form fields
    //var nowTemp = new Date();
    //var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
    
    
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth() + 1; //January is 0!

    var yyyy = today.getFullYear();
    if (dd < 10) {
        dd = '0' + dd
    }
    if (mm < 10) {
        mm = '0' + mm
    }
    today = dd + '-' + mm + '-' + yyyy;
    $('#cita-date').val(today);
    $('#dpYears').attr('data-date', today);
    $('#dpYears').fdatepicker();

});